package cn.bjc.ascept;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.AfterAdvice;
import org.springframework.aop.AfterReturningAdvice;

import java.lang.reflect.Method;

/**
 * @program: airspringaop
 * @description:
 * @author: bjc
 * @create: 2020-08-30 17:20
 */
public class DoAroundAspect implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        //方法名
        String name = methodInvocation.getMethod().getName();
        System.out.println(name+"环绕增强开始");
        Object result = null;
        try {
            result = methodInvocation.proceed();
            //System.out.println("result : "+ result);
        } catch (Throwable e) {
            e.printStackTrace();
        }
        System.out.println(name+"环绕增强结束");
        return result;
    }
}
